//
//  PTRequireTwo.swift
//  PointTest28
//
//  Created by sc-chen on 2023/6/25.
//

import SwiftUI

struct PTRequireTwo: View {
    @State var showingOptions = false
    
    var body: some View {
        List {
            ForEach(PTFuncRequireOther.allCases) { idcase in
                NavigationLink {
                    PTTwoAnyDetail.init(funcOther: idcase)
                        .toolbar {
                            ToolbarItem(placement: .destructiveAction, content: {
                                Button(action: {
                                    showingOptions = true
                                }) {
                                    Image(systemName: "ellipsis")
                                }
                                .buttonStyle(.plain)
                            })
                        }
                        .confirmationDialog("", isPresented: $showingOptions) {
                            NavigationLink("详情", destination: PTFunDetailView(ptFunc: idcase))
                                .buttonStyle(.plain)
                            Button(action: {
                                showingOptions = false
                            }) {
                                Text("取消")
                            }
                        }
                } label: {
                    Text(idcase.label)
                        .padding(.top,10)
                        .padding(.bottom,10)
                }
            }
        }
    }
}

struct PTTwoAnyDetail: View {
    let funcOther: PTFuncRequireOther
    var body: some View {
        switch funcOther {
        case .threeWayCalling: PTOtherDiaMobile()
        case .sendMMS: PTOtherSendMsg()
        case .sendMail: PTOtherEmail()
        case .mobileCommunicationNetwork: PTOtherInternet()
        case .contactModify: PTOtherContact()
        case .callLogsModify: PTOtherCallRecord()
        case .smsModify: PTOtherMsg()
        case .mmsModify: PTOtherMediaMsg()
        case .scheduleModify: PTOtherSchedule()
        case .appAutoLaunch: PTSelfLaunch()
        }
    }
}

struct PTRequireTwo_Previews: PreviewProvider {
    static var previews: some View {
        PTRequireTwo()
    }
}
